package com.ai.dylan.spring.mcp.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * 聊天响应模型，包含AI返回的内容
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ChatResponse<T> implements Serializable {
  @Serial
  private static final long serialVersionUID = 9010021685777399529L;
  private String msg;
  private String code;
  private boolean success = false;
  private T result;


  public ChatResponse(String message, String code, Boolean success) {
  }

  public static <T> ChatResponse<T> ok() {
    return new ChatResponse<T>("200", "请求成功", true);
  }

  public static <T> ChatResponse<T> ok(T result) {
    ChatResponse<T> baseResponse = new ChatResponse<T>();
    baseResponse.setCode("200");
    baseResponse.setMsg("请求成功");
    baseResponse.setSuccess(true);
    baseResponse.setResult(result);
    return baseResponse;
  }

  public static <T> ChatResponse<T> error(String message, String code) {
    return new ChatResponse<T>(message, code, null);
  }
}
